using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Events;
using Yoozoo.UI;
using Yoozoo.UI.YGUI;

public class YEffectContainerBinder : BinderBase
{
    public enum AttributeType : int
    {
        effectTime,
        offset,
        euler,
        scale,
        isAsync,
        layer,
        onEnd,
        parentName,
        prefabName,
        enabled,
    }
    
    private YEffectContainer _target;
    
    public YEffectContainerBinder(UIExpansion owner, LinkerConfig config) : base(owner, config)
    {
    }

    public YEffectContainerBinder()
    {
        
    }

    public override void Dispose()
    {
        _target = null;
        base.Dispose();
    }

    public override void Init(LinkerConfig config)
    {
        GameObject targetGo = _owner.GetStoredGameObject(config.StoredGameObjectIndex);
        if (targetGo == null)
        {
            return;
        }
        _target = targetGo.GetComponent<YEffectContainer>();
        _active = _target != null;
    }
    public override void SetSingle(float value)
    {
        switch ((AttributeType)Enum.Parse(typeof(AttributeType), _linkerType))
        {
            case AttributeType.effectTime:
                _target.effectTime = value;
            break;
            default:
            break;
        }
        base.SetSingle(value);
    }
    
    public override void SetVector3(Vector3 value)
    {
        switch ((AttributeType)Enum.Parse(typeof(AttributeType), _linkerType))
        {
            case AttributeType.offset:
                _target.offset = value;
            break;
            case AttributeType.euler:
                _target.euler = value;
            break;
            case AttributeType.scale:
                _target.scale = value;
            break;
            default:
            break;
        }
        base.SetVector3(value);
    }
    
    public override void SetBoolean(bool value)
    {
        switch ((AttributeType)Enum.Parse(typeof(AttributeType), _linkerType))
        {
            case AttributeType.isAsync:
                _target.isAsync = value;
            break;
            case AttributeType.enabled:
                _target.enabled = value;
            break;
            default:
            break;
        }
        base.SetBoolean(value);
    }
    
    public override void SetString(string value)
    {
        switch ((AttributeType)Enum.Parse(typeof(AttributeType), _linkerType))
        {
            case AttributeType.layer:
                _target.layer = value;
            break;
            case AttributeType.parentName:
                _target.parentName = value;
            break;
            case AttributeType.prefabName:
                _target.prefabName = value;
            break;
            default:
            break;
        }
        base.SetString(value);
    }
    
    public override void SetAction2(UnityAction action)
    {
        switch ((AttributeType)Enum.Parse(typeof(AttributeType), _linkerType))
        {
            case AttributeType.onEnd:
                _target.onEnd.AddListener(action);
            break;
            default:
            break;
        }
        base.SetAction2(action);
    }
    
    public override void RemoveAction2(UnityAction action)
    {
        switch ((AttributeType)Enum.Parse(typeof(AttributeType), _linkerType))
        {
            case AttributeType.onEnd:
                _target.onEnd.RemoveListener(action);
            break;
            default:
            break;
        }
        base.RemoveAction2(action);
    }
    
    public override void RemoveAllAction()
    {
        switch ((AttributeType)Enum.Parse(typeof(AttributeType), _linkerType))
        {
            case AttributeType.onEnd:
                _target.onEnd.RemoveAllListeners();
            break;
            default:
            break;
        }
    }
    
}